<?

if ($c = stack('name')) {

	$_id_component	= $DATA['components'][$c]['id'];			//	list id value
	$_id_data		= D_MB_DATA;			//	meta id value
	$_id_meta		= D_MB_META;			//	meta id value
	
	$_num_rows 		= 4;	// number of table rows
	$_num_cols 		= 12;	// number of table columns
	
	$_crit = "id_data=$_id_data AND id_parent=$_id_component AND attr & ".AA_VISIBLE;


	$s = array_extend( array(
		'path' => 'project', 'w' => 128, 'h' => 96, 'param' => 'id', 'sw' => 640, 'sh' => 390
	), component_settings($c));
	
	$dx = array('rows' => $_num_rows, 'cols' => $_num_cols);

	$dx['today'] = parse_today();
	$dx['years'] = array(2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019);
	$dx['year'] = (($x = (int)param('year')) && in_array($x, $dx['years'])) ? $x : $dx['today']['y'];
	$dx['months'] = array('Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль','Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь');
	
	
	
	$dx['objects'] = array_mark_bounds( datafetch_array('db_list', array('table' => tb('data'), 'where' => "$_crit", 'order' => 'id_index', 'index' => 'id' )));
	
	$dx['m'] = array(0,array(),array(),array(),array(),array(),array(),array(),array(),array(),array(),array(),array());

	foreach($dx['objects'] as $k => $v) {
		$v = array_merge($v, datafetch_array('meta', $_id_meta, $k, $CONTEXT['lang']));
		if ($v['year'] == $dx['year']) {
			$v['image'] = checkImage(FP_UPLOAD_PATH.$s['path'], $k);
			$dx['m'][(int)$v['month']][] = $v;
		}
	}

	$dx['categories'] = component_data('categories');
	
	
	
	
	$DATA['components'][$c]['data'] = $dx;
}

unstack();